package gift4friend.shared.core;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.NotPersistent;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import org.codehaus.jackson.annotate.JsonIgnore;

public class User implements Serializable {

	@NotPersistent
	public static final String MALE = "MALE";

	@NotPersistent
	public static final String FEMALE = "FEMALE";

	@NotPersistent
	private static final long serialVersionUID = 4918382965926503226L;

	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	@JsonIgnore
	private Long id;

	@Persistent
	private String name = new String();

	@Persistent
	private String lastName = new String();

	@Persistent
	private Date birthDate = new Date();

	@Persistent
	private String email = new String();

	@Persistent
	private String gender;

	@NotPersistent
	private Boolean loggedIn = false;

	@Persistent
	private Boolean firstVisit = true;

	@Persistent
	private String loginUrl;
	
	@Persistent
	private String logoutUrl;
	
	public String getLoginUrl() {
		return loginUrl;
	}

	public void setLoginUrl(String loginUrl) {
		this.loginUrl = loginUrl;
	}

	public String getLogoutUrl() {
		return logoutUrl;
	}

	public void setLogoutUrl(String logoutUrl) {
		this.logoutUrl = logoutUrl;
	}

	@Persistent
	private List<Product> products = new ArrayList<Product>();

	@Persistent
	private List<Likeable> likeables = new ArrayList<Likeable>();

	public User() {

	}

	public User(String name, String lastName, String email, Date birthDate,
			String gender) {
		super();
		this.name = name;
		this.lastName = lastName;
		this.email = email;
		this.birthDate = birthDate;
		this.gender = gender;
	}

	public String getGender() {
		return gender;
	}

	public void setGender(String gender) {
		this.gender = gender;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public Date getBirthDate() {
		return birthDate;
	}

	public void setBirthDate(Date birthDate) {
		this.birthDate = birthDate;
	}

	public Boolean getLoggedIn() {
		return loggedIn;
	}

	public void setLoggedIn(Boolean loggedIn) {
		this.loggedIn = loggedIn;
	}

	public Boolean getFirstVisit() {
		return firstVisit;
	}

	public void setFirstVisit(Boolean firstVisit) {
		this.firstVisit = firstVisit;
	}

	public Long getId() {
		return id;
	}

	public void addProduct(Product p) {

		products.add(p);
	}

	public void removeProduct(Product p) {

		products.remove(p);
	}

	public void addLikeable(Likeable l) {

		likeables.add(l);
	}

	public void removeLikeable(Likeable l) {

		products.remove(l);
	}

	public Iterator<Product> productIterator() {
		return this.products.iterator();
	}

	public Iterator<Likeable> likeableIterator() {
		return this.likeables.iterator();
	}

}
